package com.menhai.personmanagement.controller;

import lombok.extern.slf4j.Slf4j;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import com.menhai.personmanagement.services.IMbFollowupVisitService;
import com.menhai.personmanagement.entity.MbFollowupVisit;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author shikun
 * @since 2021-12-27
 */

@Slf4j
@RestController
@RequestMapping("/mb-followup-visit")
public class MbFollowupVisitController {

     @Autowired
     private IMbFollowupVisitService mbFollowupVisitService;


     @RequestMapping("/insertVisit")
     public int insertVisit(@RequestHeader(name = "userid") String userid,MbFollowupVisit mbFollowupVisit){
          mbFollowupVisit.setUserId(userid);
          return mbFollowupVisitService.insertVisit(mbFollowupVisit);
     }

     @RequestMapping("/getVisit")
     public List getVisit(@RequestHeader(name = "userid") String userid, @RequestHeader(name = "level") String level, @Param("type") String type,@Param("hosnumarray") String hosnumarray){
          return mbFollowupVisitService.getVisit(userid, type, hosnumarray);
     }

     /**
      * @describe 首页日历
      * @param userid
      * @Return java.util.List
      * @Date 2021/12/31 16:08
      * @author shikun
      */
     @RequestMapping("/getcalendarVisit")
     public List getcalendarVisit(@RequestHeader(name = "userid") String userid){
          return mbFollowupVisitService.getcalendarVisit(userid);
     }


     /**
      * @describe 首页日历 提示dialog
      * @param userid
      * @param date
      * @Return java.util.List
      * @Date 2022/1/6 11:14
      * @author shikun
      */
     @RequestMapping("/getcalendarVisitCutDate")
     public List getcalendarVisitCutDate(@RequestHeader(name = "userid") String userid,@Param("date") String date){
          return mbFollowupVisitService.getcalendarVisitCutDate(userid,date);
     }

     @RequestMapping("/messageRemind")
     public List messageRemind(@RequestHeader("userid") String userid){
          try {
               return mbFollowupVisitService.messageRemind(userid);
          }catch (Exception e){
               e.printStackTrace();
               return null;
          }
     }

     @RequestMapping("/getWeekPlan")
     public List getWeekPlan(@RequestHeader("userid") String userid,@RequestHeader("level") String level,@Param("monday") String monday,@Param("sunday") String sunday,@Param("type") String type){
          System.out.println(type);
          return mbFollowupVisitService.getWeekPlan(userid,level,monday, sunday, type);
     }

     @RequestMapping("/changeVisit")
     public int changeVisit(@Param("id") int id){
          return mbFollowupVisitService.changeVisit(id);
     }

     @RequestMapping("/delVisit")
     public int delVisit(@Param("id") int id){
          return mbFollowupVisitService.delVisit(id);
     }

     @RequestMapping("/editSave")
     public int editSave(MbFollowupVisit mbFollowupVisit){
          return mbFollowupVisitService.editSave(mbFollowupVisit);
     }

     @RequestMapping("/getVisitToDay")
     public List getVisitToDay(@Param("date") String date){
          return mbFollowupVisitService.getVisitToDay(date);
     }

     @RequestMapping("/gecunrenshu")
     public List gecunrenshu(@RequestHeader(name = "userid") String userid,@Param("type") String type){
          return mbFollowupVisitService.gecunrenshu(type, userid);
     }
}
